import {Component, OnInit} from '@angular/core';
import {NavParams, ModalController} from '@ionic/angular';
import {Router} from '@angular/router';
import { AppGlobalService } from '../../shared/service/app-global.service';

@Component({
    templateUrl: 'mine-copy.page.html',
    styleUrls: ['mine-copy.component.scss']
})
export class MineCopyPage implements OnInit {

    data: any;

    constructor(
        private navParams: NavParams,
        private modalCtrl: ModalController,
        public router: Router,
        private appGlobalService: AppGlobalService
    ) {
    }

    ngOnInit() {
        this.data = this.navParams.data.value;
    }

    dismiss() {
        this.modalCtrl.dismiss();
    }

    targetObj: any = {
        forward: {},  //跳转相关参数
        path: '',     //跳转路由
        bat: [],        //记录每次跳转的参数
        way: ''
    };
    link(obj) {
        const params = {
            pageId: obj.target,
            params: obj.param[0],
            sessionId: localStorage.getItem('sessionId')
        };
        this.appGlobalService.goToForward(params);
        this.modalCtrl.dismiss();
    }


    /**
     * 点击头像跳转
     *
     * @memberof MinePage
     */
    navLink() {
        const params = {
            pageId: this.data['data']['link']['target'],
            params: {
                id: this.data['data']['userId']
            },
            sessionId: localStorage.getItem('sessionId')
        };
        this.appGlobalService.goToForward(params);
        this.modalCtrl.dismiss();
    }
}
